package com.dalin.platform.loa.model;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.dalin.common.base.BaseObject;
import com.dalin.platform.loa.condition.LoaOperateHeaderCondition;
import com.dalin.platform.pub.PlatContext;
/*****************************************************************************
 * @content: 类信息                                                                                                                                *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-12-29 14:47:47                                            *
 * @modDate: 2010-12-29 14:47:47                                            *
 * @version: 1.00                                                           *
 ****************************************************************************/
@Entity
@Table(name="LOA_OPERATE")
public class LoaOperateEntity extends BaseObject{
	private Long operateId; // OPERATE_ID,16,0,序号
	private Long menuId; // 
	private String requestParam; // 
	private Integer operateCode; // OPERATE_CODE,8,0,操作代码
	private String operateName; // OPERATE_NAME,256,0,操作名称
    private String iconClsPath; // ICON_CLS_PATH,1024,0,操作(背景)图片
    private String methodName; // OPERATE_METHOD,256,0,方法名
    private String operateTip; // OPERATE_TIP,256,0,操作提示
    private Integer orderNumber; // ORDER_NUMBER,8,0,顺序
    private Long parentOperateId; // 
    private String operateDescription; // 




    @Id
    @Column(name="OPERATE_ID")
    @GeneratedValue(strategy = GenerationType.TABLE,generator="generator_normal")
    @TableGenerator(
        name = "generator_normal",
        table = "GLB_GENERATOR_KEY",
        pkColumnName = "GEN_KEY",
        valueColumnName = "GEN_VALUE",
        pkColumnValue = "LOA_OPERATE",
        allocationSize=1
    )
    public Long getOperateId() {
        return operateId;
    }

    public void setOperateId(Long operateId) {
        this.operateId = operateId;
    }
    
    @Column(name="MENU_ID")
    public Long getMenuId() {
		return menuId;
	}

	public void setMenuId(Long menuId) {
		this.menuId = menuId;
	}

	@Column(name="PARENT_OPERATE_ID")
	public Long getParentOperateId() {
		return parentOperateId;
	}

	public void setParentOperateId(Long parentOperateId) {
		this.parentOperateId = parentOperateId;
	}

	@Column(name="OPERATE_DESCRIPTION")
	public String getOperateDescription() {
		return operateDescription;
	}

	public void setOperateDescription(String operateDescription) {
		this.operateDescription = operateDescription;
	}

	@Column(name="REQUEST_PARAM")
	public String getRequestParam() {
		return requestParam;
	}

	public void setRequestParam(String requestParam) {
		this.requestParam = requestParam;
	}

	@Column(name="OPERATE_TIP")
    public String getOperateTip() {
        return operateTip;
    }

    public void setOperateTip(String operateTip) {
        this.operateTip = operateTip;
    }

    @Column(name="OPERATE_CODE")
    public Integer getOperateCode() {
        return operateCode;
    }

    public void setOperateCode(Integer operateCode) {
        this.operateCode = operateCode;
    }

    @Column(name="ORDER_NUMBER")
    public Integer getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(Integer orderNumber) {
        this.orderNumber = orderNumber;
    }

    @Column(name="METHOD_NAME")
    public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

    @Column(name="OPERATE_NAME")
    public String getOperateName() {
        return operateName;
    }

    public void setOperateName(String operateName) {
        this.operateName = operateName;
    }

    @Column(name="ICON_CLS_PATH")
    public String getIconClsPath() {
        return iconClsPath;
    }

    public void setIconClsPath(String iconClsPath) {
        this.iconClsPath = iconClsPath;
    }

    @Transient
    public List<LoaOperateHeaderEntity> getLoaOperateHeaderEntitys() throws Exception {
    	LoaOperateHeaderCondition cond = new LoaOperateHeaderCondition();
    	cond.setOperateId(operateId);
		return PlatContext.getDao().queryObjsToPages(cond.prepareParams()
				.getPreparedPageQuery());
	}
    
    
    @Transient
    public LoaMenuEntity getLoaMenuEntity() throws Exception {
		return (LoaMenuEntity) PlatContext.getDao()
			.findObjById(LoaMenuEntity.class, this.getMenuId());
	}
    
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof LoaOperateEntity)) return false;
        final LoaOperateEntity other = (LoaOperateEntity) o;
        if (iconClsPath == null) {
            if (other.iconClsPath != null) return false;
        } else if (!iconClsPath.equals(other.iconClsPath)) {
            return false;
        }
        if (operateTip == null) {
            if (other.operateTip != null) return false;
        } else if (!operateTip.equals(other.operateTip)) {
            return false;
        }
        if (operateCode == null) {
            if (other.operateCode != null) return false;
        } else if (!operateCode.equals(other.operateCode)) {
            return false;
        }
        if (orderNumber == null) {
            if (other.orderNumber != null) return false;
        } else if (!orderNumber.equals(other.orderNumber)) {
            return false;
        }
        if (methodName == null) {
            if (other.methodName != null) return false;
        } else if (!methodName.equals(other.methodName)) {
            return false;
        }
        if (operateName == null) {
            if (other.operateName != null) return false;
        } else if (!operateName.equals(other.operateName)) {
            return false;
        }
        if (operateId == null) {
            if (other.operateId != null) return false;
        } else if (!operateId.equals(other.operateId)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int njlrst = 17;
        njlrst = 31 * njlrst + (iconClsPath == null ? 0 : iconClsPath.hashCode());
        njlrst = 31 * njlrst + (operateTip == null ? 0 : operateTip.hashCode());
        njlrst = 31 * njlrst + (operateCode == null ? 0 : operateCode.hashCode());
        njlrst = 31 * njlrst + (orderNumber == null ? 0 : orderNumber.hashCode());
        njlrst = 31 * njlrst + (methodName == null ? 0 : methodName.hashCode());
        njlrst = 31 * njlrst + (operateName == null ? 0 : operateName.hashCode());
        njlrst = 31 * njlrst + (operateId == null ? 0 : operateId.hashCode());
        return njlrst;
    }

}
